/*
 * Thomas Weichselbaumer
 * mini-drone
 * main.c
 *
 */

/* Header Files */

#include <LPC214x.h>
#include <math.h>
#include <stdio.h>

#include "main.h"
#include "serial.h"


#define PIN16 0x10000

void wait (void)  { 					   /* wait function */
  int  d;
  for (d = 0; d < 1000000; d++);		   /* only to delay for LED flashes */
}

/* main method */

/* init method */
void init (void)
{
    init_serial();
	/* PLL0 Configuration */
	PLL0CFG = 0x4;	/* M = 5; CCLK = 5 * 12MHz = 60MHz */
	PLL0CFG |= 1<<5; /* P = 2; CCO = 2 * 2 * 60MHz = 240MHz */
	
	/* APB DIVIDER */
	VPBDIV = 0x0; /* PCLK = 15 MHz */
	
	/* Serial Configuration Bautrate = 115200 bit/s */
}

/* main loop - 1kHz */
void loop (void)
{
    sendchar('A');
	printf("Hello world!\n");
}

int main (void)
{
    IODIR0 = PIN16;
	init();
    
    
    IOSET0 = PIN16;
    wait();
	while(1)
	{
		loop();
	}
}
